# 华三设备SSH配置脚本
# 设备名称：{{ sysname }}
# 生成时间：{{ now().strftime('%Y-%m-%d %H:%M:%S') }}

system-view

# 配置设备名称
sysname {{ sysname }}

{% if mgmt_vlan %}
    # 创建管理VLAN
    vlan {{ mgmt_vlan }}
    description mgmt
    quit
{% endif %}

{% if mgmt_ip and mgmt_mask %}
    # 配置VLAN接口IP
    interface Vlan-interface{{ mgmt_vlan }}
    description mgmt
    ip address {{ mgmt_ip }} {{ mgmt_mask }}
    quit
{% endif %}

{% if gateway %}
    # 配置默认路由
    ip route-static 0.0.0.0 0 {{ gateway }}
{% endif %}

# 配置SSH参数
ssh server enable
sftp server enable

{% if user and password %}
    # 创建本地用户
    local-user {{ user }} class manage
    password simple {{ password }}
    service-type ssh
    undo service-type telnet
    authorization-attribute user-role level-15

    quit
{% endif %}

# 配置用户界面
line class vty
authentication-mode scheme
quit

# 保存配置
return
save force
